<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户信息管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">用户信息后台系统</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>

            <li class="layui-nav-item layui-hide-xs"><a href="">日志系统</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="">第三方服务系统</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="">计费系统</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">扩展组件</a>
                <dl class="layui-nav-child">
                    <dd><a href="">云服务支撑</a></dd>
                    <dd><a href="">短信业务</a></dd>
                    <dd><a href="">邮件业务</a></dd>
                </dl>
            </li>


        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img" id="myHeader">
                    <span id="myName">测试账户</span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">个人信息</a></dd>
                    <dd><a href="">设置</a></dd>
                    <dd><a href="">退出</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">用户管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="user/user.html">账户管理</a></dd>
                        <dd><a href="user/department.html">部门管理</a></dd>
                        <dd><a href="user/auth.html">权限管理</a></dd>
                        <dd><a href="user/weather.html">天气信息</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">商品管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">规格管理</a></dd>
                        <dd><a href="javascript:;">参数管理</a></dd>
                        <dd><a href="">商品名称管理</a></dd>
                        <dd><a href="">商品信息管理</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <!-- 面包屑导航 -->
            <span class="layui-breadcrumb">
              <a href="index.html">首页</a>
              <a><cite>个人信息</cite></a>
            </span>

            <!-- 水平线 -->
            <hr class="layui-bg-blue">

            <!-- 个人信息 -->
            <fieldset class="layui-elem-field">
                <legend>个人信息</legend>

                <div class="layui-field-box">
                    <div class="layui-form-item layui-form-pane">
                        <div class="layui-upload">
                            <div class="layui-upload-list">
                                <img class="layui-upload-img" src="" id="demo1" style="width: 100px; height: 100px">
                                <p id="demoText"></p>
                            </div>
                            <button type="button" class="layui-btn" style="margin-bottom: 20px" id="test1">上传头像</button>
                        </div>



                    <div class="layui-form-item layui-form-pane">
                        <label class="layui-form-label">账户名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="yongHuMingCheng" placeholder="账户名称" class="layui-input" readonly>
                        </div>
                    </div>

                    <div class="layui-form-item layui-form-pane">
                        <label class="layui-form-label">用户姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="xingMing" placeholder="用户姓名" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item layui-form-pane">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-inline">
                            <input type="text" id="lianXiFangShi" placeholder="联系方式" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item layui-form-pane">
                        <label class="layui-form-label">角色名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="jueSeId" placeholder="角色名称" class="layui-input" readonly>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-pane">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="chuangJianShiJian" placeholder="创建时间" class="layui-input" readonly>
                        </div>
                    </div>

                    <div class="layui-form-item layui-form-pane">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-inline">
                            <input type="text" id="zhuangTai" placeholder="状态" class="layui-input" readonly>
                        </div>
                    </div>
                </div>
                <button type="button" class="layui-btn" style="margin-top: 5px; margin-bottom: 30px; margin-left: 15px; background-color: cornflowerblue" id="gengXin">更新资料</button>
            </fieldset>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        ©2020-2021 CopyRight Hernie  www.hernie.com
    </div>
</div>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="jquery/jquery-3.5.1.js"></script>
<script>
    //JS

    $(function (){
        var user = localStorage.getItem("user")
        user = JSON.parse(user);
        $("#myHeader").attr("src", user.photoPath);
        $("#demo1").attr("src", user.photoPath);
        $("#myName").text(user.username);
    });
    layui.use(['element', 'layer', 'upload','util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,upload = layui.upload
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,title: '更多'
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                    ,scrollbar: false
                });
            }
        });


            //常规使用 - 普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                ,url: '/upload/header' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });

                    element.progress('demo', '0%'); //进度条复位
                    layer.msg('上传中', {icon: 16, time: 0});
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg(res.msg);
                    }
                    //上传成功的一些操作
                    var user = localStorage.getItem("user");
                    user = JSON.parse(user);
                    user.photoPath = res.data();
                    $("#myHeader").attr("src", user.photoPath);
                    localStorage.setItem("user", JSON.stringify(user));
                    $('#demoText').html(''); //置空上传失败的状态
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
                //进度条
                ,progress: function(n, elem, e){
                    element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
                    if(n == 100){
                        layer.msg('上传完毕', {icon: 1});
                    }
                }
            });

    });
</script>
</body>
</html>
